home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 2000 January
/
Macworld (2000-01).dmg
/
Mac OS 9 Updaters
/
Utilities
/
Reaper 131
/
Source Code
/
Reaper Utils.c
< prev
next >
Wrap
Text File
|
1999-11-10
|
5KB
|
211 lines
// AKUA Protos
/////////////////////////////
//
// Includes Beg
//
#define STANDALONER TRUE
#include "yLibCfg.h"
#include "Reaper.h"
#ifndef _yFixedMath
#include "yFixedMath.h"
#endif // _yFixedMath
#ifndef _yStringH
#include "yString.h"
#endif // _yStringH
#include <Devices.h>
//
// Includes End
//
/////////////////////////////
/*****************************************************************************************************************\
File: cdev.c
Version: 1.10
Contains: 'OAGT' Object Agent for OdoClock
Written by: Gregory Mathias Lemperle-Kerr
Copyright: ©1992-1996 worldwide by AKUA Interactive Media, Inc. All rights reserved
Usage: This file contains the code for an 'OAGT' that dynamically connects to
the 'cdev' to handle the window object. Messages from the Finder are translated
to standard window agent messages and passed on to the OAGT who may pass them
on to panel object agents.
To Do:
History:
110 GOD 19.03.1997 Added speech
100 GOD 15.05.1996 Start
\*****************************************************************************************************************/
// AKUA Statics Beg
static oaVal oaFiVolumeTrash(oaObj fcObj);
static bool fiVolumeDesktopTest(VolRef suspect, ident creator, FileRef * dtdbRef);
#if ISAPPC
static pascal OSErr PBXGetVolInfoSyncPre85(XVolumeParamPtr paramBlock);
#endif // ISAPPC
// AKUA Statics End
appItem rpFindApp(BADAPP prefH, ident creator, StringPtr name, bool onlyROM, int * idx, bool * matchedName)
{
bool nmat;
badApp pref = *prefH;
int cnt = pref->cnt;
appItem item = pref->item;
StringPtr inam = mcSlutString(mcPrefSlutX(item, cnt));
appItem found = NULL;
int fidx = -1;
for(int appIdx = 0; appIdx < cnt; appIdx ++, item ++, inam += 1 + *inam)
if ( (item->creator == creator) && (onlyROM || !mcObjTst(item, bbaOnlyIfROM))
&& ( (nmat = (mcObjTst(item, bbaByName) && stEqualP(name, inam))) || !found) )
{
found = item;
fidx = appIdx;
if (matchedName)
*matchedName = nmat;
}
if (idx)
*idx = fidx;
return found;
}
appItem rpFindApp(BADAPP prefH, RsrcFileRef ref, ident creator)
{
FileSpec appSpec;
if (!fiRefToSpec(ref, &appSpec))
{
bool rom = mcFlagTst(GetResFileAttrs(ref), mapReadOnly) || !fiVolumeIsWritable(appSpec.vRefNum);
// rpFindApp must Check for ROM!
return rpFindApp(prefH, creator ? creator : fiOrderGet(&appSpec), appSpec.name, rom, NULL, NULL);
}
return NULL;
}
appItem rpFindApp(BADAPP prefH, fileSpec appSpec, ident creator)
{
bool rom = !fiVolumeIsWritable(appSpec->vRefNum);
// rpFindApp must Check for ROM!
return rpFindApp(prefH, creator ? creator : fiOrderGet(appSpec), appSpec->name, rom, NULL, NULL);
}
appItem rpFindApp(BADAPP prefH, ProcessNum pn)
{
if (*osCurApName <= 31)
{
ProcessSN appSN;
ProcessInfoRec appInfo;
FileSpec appSpec;
// Check if we are allowed to…
appInfo.processInfoLength = sizeof(appInfo);
appInfo.processName = NULL;
appInfo.processAppSpec = &appSpec;
appSN.highLongOfPSN = 0;
appSN.lowLongOfPSN = kCurrentProcess;
GetProcessInformation(&appSN, &appInfo);
return rpFindApp(prefH, &appSpec, appInfo.processSignature);
}
return NULL;
}
short rpFindHeap(BADAPP prefH, fileSpec app, bool onlyROM)
{
// rpFindApp must Check for ROM!
if (appItem item = rpFindApp(prefH, fiOrderGet(app), app->name, onlyROM, NULL, NULL))
return item->reap;
return onlyROM ? (*prefH)->reapROM : (*prefH)->reapRWM;
}
long rpFindHeapSize(BADAPP prefH, FileRef ref, long heap)
{
FileSpec appSpec;
fiRefToSpec(ref, &appSpec);
if (short adjust = rpFindHeap(prefH, &appSpec,
mcFlagTst(GetResFileAttrs(ref), mapReadOnly) || !fiVolumeIsWritable(appSpec.vRefNum))) // Seems to be shifted in MacOS 8.51?!?
{
// DebugStr(appSpec.name);
heap += rpCalcHeapAdd(heap, adjust);
}
return heap;
}
long rpCalcHeapAdd(long heap, short adjust)
{
long more;
// Go to KB
heap >>= 10;
if (adjust < 0) // %age?
{
Fixed heapK = mcWordToFixed(heap);
Fixed ratio = mcFixToFixedWord(FixRatio(-adjust, 100));
more = FixMul(ratio, heapK); // Now in 4*64K
more >>= 8; // Div 256
}
else
more = ((lwrd)adjust) << 4 ; // 16K to K
more <<= 10; // Go to bytes
more &= ~0xFFL; // Clear out low 256
more += 11; // To show that we are adjusted
return more;
}
#define Y_BAREBONES TRUE // No Agencies…
#include "fiClass.c"
#include "fiFlag.c"
#include "fiRefToSpec.c"
#include "fiVolume.c"